#include "StdAfx.h"
#include "CreditReportModel.h"


CreditReportModel::CreditReportModel(void)
{
	m_id = 0;
	m_searchDate = 0;
	m_djBankTime = 0;
}


CreditReportModel::~CreditReportModel(void)
{
}

void CreditReportModel::toJson(Json::Value& resultJson)
{
	if (m_id > 0)
	{
		resultJson["creditRptID"] = m_id;
	}
	if (m_searchDate > 0)
	{
		resultJson["searchDate"] = m_searchDate;
	}
	char szContent[20000] = {0};
	m_searchDepartment = m_searchDepartment.Trim();
	if (m_searchDepartment.GetLength() > 0)
	{
		CChineseCode::Convert(m_searchDepartment.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["department"] = szContent;
	}
	m_khjl = m_khjl.Trim();
	if (m_khjl.GetLength() > 0)
	{
		CChineseCode::Convert(m_khjl.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["khjl"] = szContent;
	}
	m_ajjl = m_ajjl.Trim();
	if (m_ajjl.GetLength() > 0)
	{
		CChineseCode::Convert(m_ajjl.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["ajjl"] = szContent;
	}
	m_consumerName = m_consumerName.Trim();
	if (m_consumerName.GetLength() > 0)
	{
		CChineseCode::Convert(m_consumerName.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["consumerName"] = szContent;
	}
	m_consumerPhone = m_consumerPhone.Trim();
	if (m_consumerPhone.GetLength() > 0)
	{
		resultJson["consumerPhone"] = m_consumerPhone.GetBuffer();
	}
	m_identity = m_identity.Trim();
	if (m_identity.GetLength() > 0)
	{
		resultJson["identity"] = m_identity.GetBuffer();
	}
	m_searchBank = m_searchBank.Trim();
	if (m_searchBank.GetLength() > 0)
	{
		CChineseCode::Convert(m_searchBank.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["searchBank"] = szContent;
	}
	if (m_djBankTime > 0)
	{
		resultJson["djBankTime"] = m_djBankTime;
	}
	m_djUser = m_djUser.Trim();
	if (m_djUser.GetLength() > 0)
	{
		CChineseCode::Convert(m_djUser.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["djUser"] = szContent;
	}
	m_djWay = m_djWay.Trim();
	if (m_djWay.GetLength() > 0)
	{
		CChineseCode::Convert(m_djWay.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["djWay"] = szContent;
	}
	m_memo = m_memo.Trim();
	if (m_memo.GetLength() > 0)
	{
		CChineseCode::Convert(m_memo.GetBuffer(), szContent, CP_ACP, CP_UTF8);
		resultJson["memo"] = szContent;
	}
}

void CreditReportModel::parseFromJson(Json::Value& dataJson)
{
	m_id = dataJson["id"].asInt();
	if (!dataJson["searchDate"].isNull())
	{
		m_searchDate = dataJson["searchDate"].asInt64();
	}
	CUtils::getJsonStringField(dataJson, "department", m_searchDepartment);
	CUtils::getJsonStringField(dataJson, "khjl", m_khjl);
	CUtils::getJsonStringField(dataJson, "ajjl", m_ajjl);
	CUtils::getJsonStringField(dataJson, "consumerName", m_consumerName);
	CUtils::getJsonStringField(dataJson, "consumerPhone", m_consumerPhone);
	CUtils::getJsonStringField(dataJson, "identity", m_identity);
	CUtils::getJsonStringField(dataJson, "searchBank", m_searchBank);
	CUtils::getJsonStringField(dataJson, "djUser", m_djUser);
	CUtils::getJsonStringField(dataJson, "djWay", m_djWay);
	CUtils::getJsonStringField(dataJson, "memo", m_memo);	
	CUtils::getJsonStringField(dataJson, "picFileName", m_pictureFileName);
	CUtils::getJsonStringField(dataJson, "creditFileName", m_creditFileName);
	
	if (!dataJson["djBankTime"].isNull())
	{
		m_djBankTime = dataJson["djBankTime"].asInt64();
	}
}




